home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
FROMUTS
/
DDEPASCAL
/
DDE
/
!PC
/
h
/
flex
< prev
next >
Wrap
Text File
|
1992-02-10
|
5KB
|
139 lines
(*
* Title : flex.h
* Purpose: provide memory allocation for interactive programs requiring
* large chunks of store. Such programs must respond to memory
* full errors.
*
*)
#ifndef __flex_h
#define __flex_h
type flex_ptr = ^pointer;
(* ----------------------------- flex_alloc -------------------------------
* Description: Allocates n bytes of store, obtained from the Wimp.
*
* Parameters: flex_ptr anchor -- to be used to access allocated store
* int n -- number of bytes to be allocated
* Returns: 0 == failure, 1 == success
* Other Info: You should pass a pointer variable as the first
* parameter. The allocated store MUST then be accessed
* through this.
* This is important since the allocated store may later be
* moved (it's a shifting heap!!). If there's not enough
* store returns zero leaving anchor unchanged.
*
*)
function flex_alloc(anchor : flex_ptr; n : integer) : boolean; extern;
(* ------------------------------ flex_free -------------------------------
* Description: Frees the previously allocated store.
*
* Parameters: flex_ptr anchor -- pointer to allocated store
* Returns: void.
* Other Info: *anchor will be set to 0.
*
*)
procedure flex_free(anchor : flex_ptr); extern;
(* ------------------------------- flex_size ------------------------------
* Description: Informs caller of the number of bytes allocated
*
* Parameters: flex_ptr -- pointer to allocated store
* Returns: number of allocated bytes.
* Other Info: None.
*
*)
function flex_size(anchor : flex_ptr) : integer; extern;
(* --------------------------- flex_extend --------------------------------
* Description: Extend ot truncate the store area to have a new size.
*
* Parameters: flex_ptr -- pointer to allocated store
* int newsize -- new size of store
* Returns: 0 == failure, 1 == success.
* Other Info: None.
*
*)
function flex_extend(anchor : flex_ptr;
newsize : integer) : integer; extern;
(* --------------------------- flex_midextend -----------------------------
* Description: Extend or truncate store, at any point.
*
* Parameters: flex_ptr -- pointer to allocated store
* int at -- location within the allocated store
* int by -- extent
* Returns: 0 == failure, 1 == success
* Other Info: If by is +ve, then store is extended, and locations above
* "at" are copied up by "by".
* If by is -ve, then store is reduced, and any bytes beyond
* "at" are copied down to "at"+"by".
*
*)
function flex_midextend(anchor : flex_ptr;
at, by : integer) : integer; extern;
(* ---------------------------- flex_budge --------------------------------
* Description: Function to move flex store, when the C library needs
* to extend the heap.
*
* Parameters: int n -- number of bytes needed by C library
* void **a -- address of acquired store.
* Returns: amount of store acquired.
* Other Info: Don't call this function directly, but register it
* with the C library via:
* _kernel_register_slotextend(flex_budge);
* This will cause flex store to be moved up if the C
* library needs to extend the heap. Note that in this
* state, you can only rely on pointers into flex blocks
* across function calls which do not extend the stack and
* do not call malloc.
* The default state is flex_dont_budge, so, if required,
* this function should be registered AFTER calling
* flex_init().
*
*)
function flex_budge(n : integer; a : flex_ptr) : integer; extern;
(* -------------------------- flex_dont_budge -----------------------------
* Description: Function to refuse to move flex store, when the C library
* needs to extend the heap.
*
* Parameters: int n -- number of bytes needed by C library
* void **a -- address of acquired store.
* Returns: amount of store acquired (always 0).
* Other Info: Don't call this function directly, but register it
* with the C library via:
* _kernel_register_slotextend(flex_dont_budge);
* If the C library needs to extend the heap, flex will
* refuse to move. This means that you can rely on pointers
* into flex blocks across function calls.
* This is the DEFAULT state after flex_init().
*
*)
function flex_dont_budge(n : integer; a : flex_ptr) : integer; extern;
(* ---------------------------- flex_init ---------------------------------
* Description: Initialise store allocation module.
*
* Parameters: void.
* Returns: void.
* Other Info: Must be called before any other functions in this module.
*
*)
procedure flex_init; extern;
#endif
(* end flex.h *)